{\rtf1\ansi\ansicpg1251\cocoartf2513
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0

\f0\fs24 \cf0 #include <iostream>\
#include <unordered_map>\
#include <string>\
\
int prost(int n) \{\
    for (int i = 2; i <= n; i++) \{\
        if (n % i == 0) \{\
            return i;\
        \}\
    \}\
    return n;\
\}\
\
int mega() \{\
    std::unordered_map<std::string, int> dict_num = \{\
        \{"zero", 0\},\
        \{"one", 1\},\
        \{"two", 2\},\
        \{"three", 3\},\
        \{"four", 4\},\
        \{"five", 5\},\
        \{"six", 6\},\
        \{"seven", 7\},\
        \{"eight", 8\},\
        \{"nine", 9\}\
    \};\
\
    std::string n;\
    std::getline(std::cin, n);\
    std::string words[3];\
    int wordCount = 0;\
    std::string word = "";\
    for (char c : n) \{\
        if (c == ' ') \{\
            words[wordCount++] = word;\
            word = "";\
        \} else \{\
            word += c;\
        \}\
    \}\
    words[wordCount] = word;\
\
    if (words[0] == "zero") \{\
        return -1;\
    \}\
\
    if (wordCount != 2) \{\
        return -1;\
    \}\
\
    for (std::string w : words) \{\
        if (dict_num.find(w) == dict_num.end()) \{\
            return -1;\
        \}\
    \}\
\
    int input_num = 0;\
    for (std::string w : words) \{\
        input_num = input_num * 10 + dict_num[w];\
    \}\
\
    bool flag = true;\
    int l = 1, r = 1;\
    while (flag) \{\
        int x = input_num - l;\
        if (prost(x) == x) \{\
            return x;\
        \} else \{\
            l++;\
        \}\
        int y = input_num + r;\
        if (prost(y) == y) \{\
            return y;\
        \} else \{\
            r++;\
        \}\
    \}\
\
    return -1;\
\}\
\
int main() \{\
    std::cout << mega() << std::endl;\
    return 0;\
\}\
\
}